#include <WiFiClientSecure.h>
#include <ESP8266HTTPClient.h>

void http_get()
{
  WiFiClientSecure client;
  HTTPClient https;
  client.setInsecure();

  delay(4000);

  Serial.print("[HTTPS] begin...\n");
  if (https.begin(client, "https://www.hanlinbo.cn/weather.json"))
  { // HTTP

    Serial.print("[HTTPS] GET...\n");
    int httpCode = https.GET();

    if (httpCode > 0)
    {
      for (int i = 0; i < https.headers(); i++)
      {
        Serial.printf("%s: %s\n", https.headerName(i).c_str(), https.header(i).c_str());
      }

      Serial.printf("[HTTPS] GET... code: %d\n", httpCode);

      const char *bodyStr = https.getString().c_str();
      int size = https.getSize();
      Serial.println(String(bodyStr));
    }
    else
    {
      Serial.printf("[HTTPS] GET... failed, error: %s\n", https.errorToString(httpCode).c_str());
    }

    https.end();
  }
  else
  {
    Serial.println("[HTTP] Unable to connect");
  }
}
